package 初始线程;
//方法2：实现Runnable接口
//类似于comparable
class MyThread3 implements Runnable{

    @Override
    public void run() {
        while(true){
            System.out.println("111");
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

}
public class Demo_3 {
    public static void main(String[] args) {
        MyThread3 myThread3 = new MyThread3();
        Thread t = new Thread(myThread3,"线程001");
//        Thread t = new Thread(new MyThread3());
        t.start();
        while(true){
            System.out.println("222");
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

